﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Resto.CostControl.Core.Domain.Model;
using Resto.CostControl.Core.Cache;
using Resto.CostControl.Common.Consts;
using System.ComponentModel.DataAnnotations;

namespace Resto.CostControl.Core.Facade.SystemModule.DataTransferObject
{
    /// <summary>
    /// 字典DTO
    /// </summary>
    [Serializable]
    public class DictionaryDTO
    {
        #region 构造函数

        public DictionaryDTO() { }

        internal DictionaryDTO(Dictionary dic)
        {
            this.ID = dic.ID;
            this.Code = dic.Code;
            this.Name = dic.Name;
            this.TypeCode = dic.TypeCode;
            this.Sequence = dic.Sequence;
            this.Description = dic.Description;
            this.PingYinCode = dic.PingYinCode;
        }

        #endregion

        #region 基本属性

        public string ID { get; set; }

        /// <summary>
        /// 字典代码
        /// </summary>
        [Display(Name = "字典代码")]
        public string Code { get; set; }

        /// <summary>
        /// 字典名称
        /// </summary>
         [Display(Name = "字典名称")]
        public string Name { get; set; }

        /// <summary>
        /// 字典类型代码
        /// </summary>
         [Display(Name = "字典类型代码")]
        public string TypeCode { get; set; }

        /// <summary>
        /// 字典类型的名称
        /// </summary>
         [Display(Name = "字典类型的名称")]
        public string TypeName
        {
            get
            {
                return DictionaryVOArrayCache.GetDicNameByCode(DictionaryTypeConsts.System_DictionaryType_Code, TypeCode);
            }
        }

        /// <summary>
        /// 排序号
        /// </summary>
        [Display(Name = "排序号")]
        public int Sequence { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
       [Display(Name = "描述")] 
        public string Description { get; set; }

        /// <summary>
        /// 拼音首码
        /// </summary>
        [Display(Name = "拼音首码")]
        public string PingYinCode { get; set; }

        #endregion

        #region 方法

        internal Dictionary ToDictionary()
        {
            Dictionary dic = new Dictionary();
            CopyToDictionary(dic);
            return dic;
        }

        internal void CopyToDictionary(Dictionary dic)
        {
            dic.Code = this.Code;
            dic.Name = this.Name;
            dic.TypeCode = this.TypeCode;
            dic.Sequence = this.Sequence;
            dic.Description = this.Description;
            dic.PingYinCode = this.PingYinCode;
        }

        #endregion
    }
}
